<?
    require_once("dbconnect.php");
    require_once("admin_functions.php");
    require_once("classes/mail.php");
    //alter table `ep`.`customer` change `customer_id` `customer_id` int (11)  NOT NULL AUTO_INCREMENT , add primary key(`customer_id` )

    chk_session();

    if(!empty($_GET) && $_GET['action'] == "APPROVE") {
        $query_data = "Update customer set status='Y' where customer_id=".$_REQUEST['cuid'];
        $result_update	= mysql_query ( $query_data ) or die(mysql_error());
        $message ='<div class="update_message">Customer id:'.$_REQUEST['cuid'].' is approved.</div>';
    }

    if(!empty($_GET) && $_GET['action'] == "CANCEL") {
        $query_data = "Update customer set status='C' where customer_id=".$_REQUEST['cuid'];
        $result_update	= mysql_query ( $query_data ) or die(mysql_error());
        $message ='<div class="update_message">Customer id:'.$_REQUEST['cuid'].' is cancelled.</div>';
    }

    $sql1 = "SELECT customer.*,nativeplace.nativeplace
             FROM (customer INNER JOIN nativeplace ON
            customer.city = nativeplace.nativeplace_id) INNER JOIN community ON
            customer.community = community.community_id WHERE customer.status = 'N' ORDER BY customer.customer_id DESC";

    $rs1 = mysql_query($sql1) or die(mysql_error());
    $cnt1 = mysql_num_rows($rs1);
?>

<?php require_once('include/header1.php'); ?>
<?php require_once('include/sidebar.php'); ?>
<div id="admin_full_inner_body">
    <div id="page_heading">Manage Customer </div>
    <?php
    if(!empty ($message)){
        echo $message;
    }
    ?>
    <table cellpadding="0" cellspacing="0" border="0" class="display" id="example" width="100%">
        <thead>
            <tr>
                <th>Customer ID</th>
                <th>Gender</th>
                <th>Customer Info</th>
                <th>Image</th>
                <th>Expectation</th>
                <th>Last Online</th>
                <th>Status</th>
                <th>Action</th>
            </tr>
        </thead>
        <tbody>
            <?php while($row1=mysql_fetch_array($rs1)) { ?>
            <tr class="odd gradeX">
                <td><a href="../profile.php?cid=<?php echo $row1['customer_id']; ?>"><?php echo $row1['customer_id']; ?></a></td>
                <th><?php echo $row1['gender']; ?></th>
                <td><?php echo $row1['name']; ?>
                        <?php echo $row1['age']; ?>, <?php echo $row1['feetInch']; ?> Inch.,
                        <?php echo $row1['occupation']; ?>, <?php echo $row1['nativeplace']; ?></td>
                <td>

                    <?php if(!empty($row1['image_1']) && file_exists("../uploaded/thumb/".$row1['image_1'])){ ?>
                    <img src="../uploaded/thumb/<?=$row1['image_1']?>"  border="0" class="image_border">
                  <?php } else { ?>
                    <?php if($row1['gender'] == 'Male') { ?>
                    <img src="images/default_eparinay_groom.jpg" width="50" height="50" border="0" class="image_border">
                            <?php } else { ?>
                    <img src="images/default_eparinay_bride.jpg" width="50" height="50" border="0" class="image_border" >
                     <?php } ?>
              <?}?>


                </td>
                <td class="center"> <?=stripslashes(substr($row1['expectation'],0,200)) ?></td>
                <td class="center"><?= !empty($row1['online']) ? $row1['online'] : "12-Febuary-2012" ?></td>
                <td class="center"><?= $row1['status']; ?></td>
                <th><a href="JavaScript:if(confirm('Are you sure you want to approve this Customer?')){self.location.href='manage_customer.php?cuid= <?php echo $row1['customer_id']; ?>&action=APPROVE';}"
                       class="link-normal">Approve</a>&nbsp;|
                   <a href="JavaScript:if(confirm('Are you sure you want to Delete this Customer?')){self.location.href='manage_customer.php?cuid=<?php echo $row1['customer_id']; ?>&action=CANCEL';}"
                       class="link-normal">Cancel</a></th>
            </tr>
                <?php } //end while ?>

        </tbody>
        <tfoot>
            <tr>
                <th>Customer ID</th>
                <th>Gender</th>
                <th>Customer Info</th>
                <th>Image</th>
                <th>Expectation</th>
                <th>Last Online</th>
                <th>Status</th>
                <th>Action</th>
            </tr>
        </tfoot>
    </table>
</div>

<!-- middle_container ends -->
<?php require_once('include/footer1.php'); ?>
